﻿using System;
using System.IO;

namespace SourcesUnPacker
{
    public class RoleImage
    {
        public int OffsetX { get; set; }
        public int OffsetY { get; set; }
        public int SizeX { get; set; }
        public int SizeY { get; set; }
        public int RleNumber { get; set; }
        public int RleIndex { get; set; }
        public int SourceX { get; set; }
        public int SourceY { get; set; }


        public override string ToString()
        {
            return "RoleImage{" +
                   "OffsetX=" + OffsetX +
                   ", OffsetY=" + OffsetY +
                   ", SizeX=" + SizeX +
                   ", SizeY=" + SizeY +
                   ", RleNumber=" + RleNumber +
                   ", RleIndex=" + RleIndex +
                   ", SourceX=" + SourceX +
                   ", SourceY=" + SourceY +
                   '}';
        }

        public static RoleImage read(BinaryReader reader)
        {
            var image = new RoleImage
            {
                OffsetX = reader.ReadInt32(),
                OffsetY = reader.ReadInt32(),
                SizeX = reader.ReadInt32(),
                SizeY = reader.ReadInt32(),
                RleNumber = reader.ReadInt32(),
                RleIndex = reader.ReadInt32(),
                SourceX = reader.ReadInt32(),
                SourceY = reader.ReadInt32()
            };
            //打印RoleImage
            
            return image;
        }
    }
}